function MessageModel() {
    this.type = "";
    this.content = "";
    this.userAccount = "";
    this.userNickName = "";
    this.userIcon = "";
    this.userTarget = "";
}

MessageModel.prototype = {
    constructor: MessageModel,
    setType: function (type) {
        this.type = type;
        return this
    },
    setContent: function (content) {
        this.content = content;
        return this
    },
    setUserAccount: function (userAccount) {
        this.userAccount = userAccount;
        return this
    },
    setuserNickName: function (userNickName) {
        this.userNickName = userNickName;
        return this;
    },
    setUserIcon: function (userIcon) {
        this.userIcon = userIcon;
        return this
    },
    setUserTarget: function (userTarget) {
        this.userTarget = userTarget;
        return this
    }
};

function ContentBubble(icon, type, content) {
    this.userIcon = icon;
    this.contentType = type;
    this.content = content;
}

var windowList = {};
windowList.chatWindow = [];

/*****************聊天气泡*********************/
$.sendMsg = function (rgb, content, type) {
    $.formatElement = function (rgb, content) {
        var bubble = '<div>' +
            '<span class="userIcon float_' + type + '" style="background: rgb(' + rgb + ');"></span>' +
            '<span class="message_' + type + '">' +
            '<p class="content_words">' + content + '</p>' +
            '</span>' +
            '</div>';
        return bubble;
    };
    var $contentBody = $(".content_body");
    $contentBody.append($.formatElement(rgb.replace(/\../g, ""), content));
    $contentBody.scrollTop($contentBody[0].scrollHeight);
};

/*****************好友列表*********************/
$.showFriendList = function (json) {
    var isOnline, element;
    json.isOnline == 0 ? isOnline = "out" : isOnline = "";
    json.userIcon = json.userIcon.replace(/\../g, "");
    element = '<li class="list_member ' + isOnline + '" id="' + json.userAccount + '">' +
        '<span class="member_icon" style="background-color: rgb(' + json.userIcon + ')"></span>' +
        '<p class="member_nickname">' + json.userNickname + '</p>' +
        '<span class="message_bubble"><p class="message_count"></p></span>' +
        '<span class="close_btn"><p>&times;</p></span>' +
        '</li>';
    $(".windows_list").append(element);
};

/*****************聊天列表*********************/
$.showChatList = function (json, active) {
    if (!json.userIcon.indexOf("rgb") == 0)
        json.userIcon = "rgb(" + json.userIcon.replace(/\../g, "") + ")";
    if (active)
        active = "focus_click";
    else active = "";
    var element = '<li class="list_member ' + active + '" id="' + json.userAccount + '">' +
        '<span class="member_icon" style="background-color: ' + json.userIcon + '"></span>' +
        '<p class="member_nickname">' + json.userNickname + '</p>' +
        '<span class="message_bubble"><p class="message_count"></p></span>' +
        '<span class="close_btn"><p>&times;</p></span>' +
        '</li>';
    $(".windows_list").append(element);
};